<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.io.*"%>
<%@ page import="xml.response.*"%>
<%@ page import="xml.root"%>
<%@ page import="util.print.printLogCat"%>
<%@ page import="org.sql.table.*"%>
<%@ page import="xml.var"%>
<%@ page import="java.util.Vector"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="jqgrid.jqgrid"%>
<%@ page import="org.util.getNewData"%>
<%@ page import="requestInterFace.Handle.*"%>
<%@ page import="org.util.SerialNumberUtil"%>
<%@ include file="../../util/paramPrint.jsp" %>
<%@ page import="util.check"%>
<%@ page trimDirectiveWhitespaces="true" %> 
<%
String name = request.getParameter("Product_Name");
String Product_Price = request.getParameter("Product_Price");
String Product_Type = request.getParameter("Product_Type");
String Product_DESC =request.getParameter("Product_DESC");//产品描述
String userType=(String)session.getAttribute("User_Type");
root root=new root();
if(userType==null||!userType.equals("1")){
root.setStatus("false");
root.setMsg("权限不够");
PrintWriter pw = response.getWriter();
pw.println(root.getXmlString());
pw.flush();
return ;
}
		
		if(name==null||name.equals("")||Product_Type==null||Product_Type.equals("")||Product_Price==null||Product_Price.equals("")){
		root.setStatus("false");
		root.setMsg("请填写正确出参数");
		PrintWriter pw = response.getWriter();
		pw.println(root.getXmlString());
		pw.flush();
		return ;
		}
		
		
		productHandle handle=new productHandle();
		if(handle.isHaveProductAndType(name,Product_Type)){
			root.setStatus("false");
			root.setMsg("记录已经存在");
			PrintWriter pw = response.getWriter();
			pw.println(root.getXmlString());
			pw.flush();
			return ;
		}
		productinfo1_1 user=new productinfo1_1();
		
		if(Product_Price!=null&&(!Product_Price.equals(""))){
		if(check.isNumeric(Product_Price)){
		 	 user.setInsertField("Product_Price",Product_Price);
		  }else{
		    root.setStatus("false");
			root.setMsg("不是正确的数值");
			PrintWriter pw = response.getWriter();
			pw.println(root.getXmlString());
			pw.flush();
			return ;
		   }
		}
		
		if(Product_Type!=null&&(!Product_Type.equals(""))){
		 user.setInsertField("Product_Type", Product_Type);
		}
		if(name!=null&&(!name.equals(""))){
		 user.setInsertField("Product_Name", name);
		}
		if(Product_DESC!=null&&!Product_DESC.equals("")){
		 user.setInsertField("Product_DESC",Product_DESC);
		}
		user.setInsertField("Product_ID",SerialNumberUtil.buildProductSn());
		user.setInsertField("Product_AddTime",getNewData.GetNowDateAndTime1());
		user.setInsertField("Product_Adder",(String)session.getAttribute("User_ID"));
		int row=user.insert();
		root.setRecords(""+row);//设置当前查询到的记录数
		if(row>0){
			root.setStatus("true");
			root.setMsg("添加成功");
		}else{
			root.setStatus("false");
			root.setMsg("添加失败");
		}
		//printLogCat.printlnWriter(root.getXmlString());
		String rep=root.getXmlString();
%>
<%=rep%>

